package com.bawei.module_my.view.adapter

import android.content.Context
import android.widget.ImageView
import com.bawei.module_base.net.bean.my.FindPrivateLetterListBean
import com.bawei.module_my.R
import com.bumptech.glide.Glide
import com.zhy.adapter.recyclerview.CommonAdapter
import com.zhy.adapter.recyclerview.base.ViewHolder
import java.text.SimpleDateFormat


class PrivateAdapter(context: Context?,
                     layoutId: Int, datas: MutableList<FindPrivateLetterListBean>?
) : CommonAdapter<FindPrivateLetterListBean>(context, layoutId, datas) {
    override fun convert(holder: ViewHolder?, t: FindPrivateLetterListBean?, position: Int) {
        holder?.setText(R.id.private_name_id,t?.nickName)
        holder?.setText(R.id.private_content_id,"交个朋友呗"+t?.messageId)
        if (t != null) {
            holder?.setText( R.id.private_time_id,transToString(t.remainderTime))
        }


        //头像
        holder?.getView<ImageView>(R.id.private_headPic_id)
            .let {
                if (it != null) {
                    Glide.with(mContext)
                        .load(t?.headPic)
                        .circleCrop()
                        .into(it)
                }
            }
    }
    fun transToString(time: Int):String{
        return SimpleDateFormat("HH:mm:ss").format(time)
    }
}